<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P62 【例3-7】demo07.html</title>
</head>

<body>
    <script>
        var arr = ['potato', 'tomato', 'chillies', 'green-pepper'];
        var search = 'cucumber';
        if (arr.indexOf(search) == -1) {
            arr.push(search);
            console.log('更新后的数组为：' + arr);
        } else if (arr.indexOf(search) > -1) {
            console.log(search + '元素已在arr数组中。');
        }
    </script>
    <a href="../首页/page03.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>